/**
 * 
 */
package com.study.timer;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author Administrator
 * @date 2019年4月27日
 */
public class ScheduledExecutorServiceTest {

	public static void main(String[] args){
		
		 ScheduledExecutorService newSingleThreadScheduledExecutor = Executors.newSingleThreadScheduledExecutor();
		
		 Runnable runnable = () -> {
			 System.out.println("newSingleThreadScheduledExecutor test..." + new SimpleDateFormat("yyyymmdd hh:MM:ss").format(new Date()));
		 };
		 
		 //立刻执行，而且每隔1000毫秒执行一次。
		 newSingleThreadScheduledExecutor.scheduleAtFixedRate(runnable, 0, 1000, TimeUnit.MILLISECONDS);
	}
}
